package datatypes;

import java.util.Date;

public abstract class Duty implements Comparable<Duty> {

	public int DID;
	public double pointsPerDuty;
	public DutyDate date;

	
	public final static int GuardDuty = 0;
	public final static int KitchenDuty = 1;
	public final static int OtherDuty = 2;
	
	public abstract double getPointsPerHourDuty();

	public Duty() {
	}

	public Duty(Date startingDate,Date endingDate) {
		setID();
		this.date = new DutyDate(startingDate,endingDate);
	}

	private int loadDID() {
		return 0;
	}

	private int saveDID(int id) {

		return 0;
	}

	static int tmp = 0;

	public void setID() {
		// this.DID = loadDID() + 1;
		this.DID = ++tmp;
		saveDID(this.DID);
	}

	public int getDID() {
		return this.DID;
	}

	public double getTotalPoints() {
		return this.getPointsPerHourDuty() * getDutyHours();
	}

	public DutyDate getDate() {
		return this.date;
	}

	private double getDutyHours() {
		return (this.date.getEndingDate().getHours() - this.date
				.getStartingDate().getHours());
	}

	@Override
	public int compareTo(Duty another) {
		return (int) (this.getDutyHours() - another.getDutyHours());
	}

	@Override
	public String toString() {
		return Integer.toString(this.DID) + " total points: "
				+ getTotalPoints();
	}

}
